package com.zide.auth.mapper.platform;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zide.auth.domain.entity.platform.PlatformUser;
import com.zide.auth.vo.result.PlatformUserResultVO;
import com.zide.auth.vo.search.PlatformUserSearchVO;
import com.zide.common.config.mybatisplus.ZiDeMapperPlus;
import com.zide.common.core.domain.PageResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * @author 石添添
 * @description
 * @date 2024-09-10 20:24
 */
@Mapper
public interface PlatformUserMapper extends ZiDeMapperPlus<PlatformUser> {
    Page<PlatformUser> selectUnallocatedList(@Param("page")  Page<PlatformUser> page,@Param("searchVO") PlatformUserSearchVO searchVO);

    default PageResult<PlatformUserResultVO> selectPage(PlatformUserSearchVO searchVO) {
        LambdaQueryWrapper<PlatformUser> wrapper = new LambdaQueryWrapper<>();
        if(StrUtil.isNotEmpty(searchVO.getMobile())) {
            wrapper.like(PlatformUser::getMobile, searchVO.getMobile());
        }
        PageResult<PlatformUser> platformUserPageResult = selectPage(searchVO, wrapper);
        PageResult<PlatformUserResultVO> result = new PageResult<>();
        BeanUtil.copyProperties(platformUserPageResult, result);
        return result;
    }
}
